﻿using J.Status.Application.Command.BookingCommand;
using J.StatusModel;
using J.StatusRepository.Interface;
using MediatR;
using StatusService;

namespace J.Status.Application.Handler.BookingHandler
{
    public class BookingOneUpdateHandler:IRequestHandler<BookingOneUpdateCommand,int>
    {
        private readonly IBookingService bookingService;
        public BookingOneUpdateHandler(IBookingService bookingService)
        {
            this.bookingService = bookingService;
        }

        public async Task<int> Handle(BookingOneUpdateCommand request, CancellationToken cancellationToken)
        {
            if (request.state==RoomStates.维修)
            {
                return await bookingService.TransactionMaintain(request.Id,request.state);
            }
            else
            {
                return await bookingService.TransactionPigsty(request.Id, request.state);
            }
        }
    }
}
